﻿using TbShop.Web.Areas.Admin.Models;
using TbShop.Web.Helpers;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc;

namespace TbShop.Web.Areas.Admin.Controllers
{
    public class SettingController : BaseController
    {

        public ActionResult Edit()
        {
            var model = new SettingViewModel();
            ConfigurationManager.RefreshSection("appSettings");
            //model.TotalMoney = ConfigurationManager.AppSettings["ManagementExpense"];
            return View(model);
        }
        [HttpPost]
        [ValidateAntiForgeryToken]
        [ValidateInput(false)]
        public ActionResult Edit(SettingViewModel item)
        {
            Configuration cfa = WebConfigurationManager.OpenWebConfiguration("~");
            //cfa.AppSettings.Settings["SingleAmount"].Value = item.SingleMoney;
            cfa.Save();
            ConfigurationManager.RefreshSection("appSettings");
            OperationLogHelper.SaveOperationLog(User.Identity.Name, ("修改"), "配置信息", "", "");
            SendMessage("保存成功", Constants.MessageType.Success);
            return RedirectToAction("Edit");
        }
    }
}